package net.xuhf.controller;

import net.xuhf.common.Result;
import net.xuhf.dto.FileDTO;
import net.xuhf.service.IFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/file")
public class FileController {

    @Autowired
    private IFileService fileService;

    @PostMapping("/upload")
    public Result<FileDTO> uploadFile(@RequestParam("file") MultipartFile file) throws Exception {
        return Result.success(fileService.upload(file));
    }
}
